<?php

namespace App\Jobs;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\DB;

class SynAccount implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }
    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //同步到数据库吧
        $redis = app('redis');
        file_put_contents('DesC.txt' , var_export(time(), true),FILE_APPEND);
//        $keys = $redis->keys("msg:account:*");
//        if($keys){
//            $reference_at =Carbon::now()->subHour(1)->toDateTimeString();
//            foreach ($keys as $accounts) {
//                $account = $redis->hgetall($accounts);
//                if(isset($account['updated_at'])) {
//                    if ($account['updated_at'] >= $reference_at) {
//                        DB::table("account")->where("email", $account['email'])->update(["updated_at" => $account['updated_at'], "status" => $account['status'], "cert" => $account['cert'], "num" => $account['num'], "Record_at" => $account['Record_at']]);
//                    }
//                }
//            }
//        }
    }
}
